/*
 * (c) Copyright Ascensio System SIA 2010-2019
 *
 * This program is a free software product. You can redistribute it and/or
 * modify it under the terms of the GNU Affero General Public License (AGPL)
 * version 3 as published by the Free Software Foundation. In accordance with
 * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
 * that Ascensio System SIA expressly excludes the warranty of non-infringement
 * of any third-party rights.
 *
 * This program is distributed WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR  PURPOSE. For
 * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
 *
 * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
 * street, Riga, Latvia, EU, LV-1050.
 *
 * The  interactive user interfaces in modified source and object code versions
 * of the Program must display Appropriate Legal Notices, as required under
 * Section 5 of the GNU AGPL version 3.
 *
 * Pursuant to Section 7(b) of the License you must retain the original Product
 * logo when distributing the program. Pursuant to Section 7(e) we decline to
 * grant you any rights under trademark law for use of our trademarks.
 *
 * All the Product's GUI elements, including illustrations and icon sets, as
 * well as technical writing content are licensed under the terms of the
 * Creative Commons Attribution-ShareAlike 4.0 International. See the License
 * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
 *
 */

#include <sstream>
#include <string>
#include <map>

#include "include/cef_dom.h"
#include "include/wrapper/cef_helpers.h"
#include "include/wrapper/cef_message_router.h"

#include "../../../core/DesktopEditor/common/File.h"
#include "../../../core/DesktopEditor/common/Directory.h"
#include "../../../core/DesktopEditor/raster/BgraFrame.h"
#include "../../../core/DesktopEditor/raster/ImageFileFormatChecker.h"
#include "../../../core/DesktopEditor/graphics/BaseThread.h"

#include "./client_app.h"
#include "../../../core/Common/FileDownloader/FileDownloader.h"

//#define ASC_HTML_FILE_INTERNAL_LOG

void client::ClientApp::RegisterCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar, std::vector<CefString> &cookiable_schemes)
{
}

namespace NSFileDownloader
{
    static bool IsNeedDownload(const std::wstring& FilePath)
    {
        std::wstring::size_type n1 = FilePath.find(L"www.");
        std::wstring::size_type n2 = FilePath.find(L"http://");
        std::wstring::size_type n3 = FilePath.find(L"ftp://");
        std::wstring::size_type n4 = FilePath.find(L"https://");

        if (n1 != std::wstring::npos && n1 < 10)
            return true;
        if (n2 != std::wstring::npos && n2 < 10)
            return true;
        if (n3 != std::wstring::npos && n3 < 10)
            return true;
        if (n4 != std::wstring::npos && n4 < 10)
            return true;

        return false;
    }
}

namespace asc_client_renderer
{
class CAscEditorNativeV8Handler : public CefV8Handler
{
public:
    std::wstring                            m_sDocumentPath;
    std::map<std::wstring, std::wstring>    m_mapImages;

    bool*                                   sync_command_check;
    std::string                             m_sPasteFrameId;

    CAscEditorNativeV8Handler()
    {
        m_sDocumentPath = L"";
        sync_command_check = NULL;
    }

    std::wstring GetImagePath(const std::wstring& sUrl, bool bIsBase64 = false)
    {
        std::map<std::wstring, std::wstring>::iterator iter = m_mapImages.find(sUrl);
        if (iter != m_mapImages.end())
        {
            return iter->second;
        }

        std::wstring sTmpPath = L"";
        if (NSFileDownloader::IsNeedDownload(sUrl))
        {
            CFileDownloader oDownloader(sUrl, false);
            oDownloader.Start( 0 );
            while ( oDownloader.IsRunned() )
            {
                NSThreads::Sleep( 10 );
            }
            if ( oDownloader.IsFileDownloaded() )
            {
                sTmpPath = oDownloader.GetFilePath();
            }
            else
            {
                std::wstring strFileName = oDownloader.GetFilePath();
                NSFile::CFileBinary::Remove(strFileName);
            }
        }
        else if (bIsBase64)
        {
            std::wstring::size_type nBase64Start = sUrl.find(L"base64,");
            if (nBase64Start != std::wstring::npos)
            {
                int nStartIndex = nBase64Start + 7;
                int nCount = sUrl.length() - nStartIndex;
                char* pData = new char[nCount];
                const wchar_t* pDataSrc = sUrl.c_str();
                for (int i = 0; i < nCount; ++i)
                    pData[i] = pDataSrc[i + nStartIndex];

                BYTE* pDataDecode = NULL;
                int nLenDecode = 0;
                NSFile::CBase64Converter::Decode(pData, nCount, pDataDecode, nLenDecode);

                RELEASEARRAYOBJECTS(pData);

                sTmpPath = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"IMG");
                if (NSFile::CFileBinary::Exists(sTmpPath))
                    NSFile::CFileBinary::Remove(sTmpPath);

                NSFile::CFileBinary oFile;
                if (oFile.CreateFileW(sTmpPath))
                {
                    oFile.WriteFile(pDataDecode, (DWORD)nLenDecode);
                    oFile.CloseFile();
                }

                RELEASEARRAYOBJECTS(pDataDecode);
            }
        }

        CImageFileFormatChecker oChecker;
        std::wstring sNoConst = sTmpPath.empty() ? sUrl : sTmpPath;
        bool bIsPNG = oChecker.isPngFile(sNoConst);

        CBgraFrame oFrame;
        bool bIsOpen = oFrame.OpenFile(sNoConst);

        std::wstring sDst = L"image" + std::to_wstring((int)(m_mapImages.size() + 1)) + (bIsPNG ? L".png" : L".jpg");

        if (bIsOpen)
            oFrame.SaveFile(m_sDocumentPath + L"/media/" + sDst, bIsPNG ? 4 : 3);

        m_mapImages.insert(std::pair<std::wstring, std::wstring>(sUrl, sDst));

        if (!sTmpPath.empty())
            NSFile::CFileBinary::Remove(sTmpPath);

        return sDst;
    }

    virtual bool Execute(const CefString& name,
                       CefRefPtr<CefV8Value> object,
                       const CefV8ValueList& arguments,
                       CefRefPtr<CefV8Value>& retval,
                       CefString& exception) OVERRIDE
    {
        if (name == "InitSDK")
        {
            std::string sDivId = "editor_sdk";
            CefRefPtr<CefV8Value> val = *arguments.begin();
            if (val->IsValid() && val->IsString())
            {
                sDivId = val->GetStringValue().ToString();
            }

            std::string sCode = "var _asc_sdk_value = new window.asc_docs_api({'id-view':\"" + sDivId + "\" });";

            CefRefPtr<CefFrame> _frame = CefV8Context::GetCurrentContext()->GetFrame();
            _frame->ExecuteJavaScript(sCode, _frame->GetURL(), 0);
            return true;
        }
        else if (name == "OpenEmptyDocument")
        {
            std::string sEmptyDocument = "DOCY;v5;36996;CACAAgAACYYCAAAIwgIAAAPGAgAABdQCAAAGHogAAASxiAAAB7WIAAAAAAA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AAAQACAQNqSgAA+wATAAAAAw4AAAAACQAAAAMEAAAA+gAO+wIHAAAA+gAAAAAA+wM0AgAAAwAAAAATAAAAAw4AAAAACQAAAAMEAAAA+gAO+wBBAQAABDwBAAD6+wAsAQAAAwAAAABUAAAA+gAAAAAA+wBIAAAAA0MAAAD6AA77ADoAAAACAAAAARQAAAD6AAQAAAB0AGkAbgB0AAFAnAAA+wEYAAAA+gA";
            sEmptyDocument += "GAAAAcwBhAHQATQBvAGQAATBXBQD7AG8AAAD6AECcAAD7AGMAAAADXgAAAPoADvsAVQAAAAMAAAABFAAAAPoABAAAAHQAaQBuAHQAAcivAAD7ARYAAAD6AAUAAABzAGgAYQBkAGUAAbiCAQD7ARgAAAD6AAYAAABzAGEAdABNAG8AZAABMFcFAPsAVgAAAPoAoIYBAPsASgAAAANFAAAA+gAO+wA8AAAAAgAAAAEWAAAA+gAFAAAAcwBoAGEAZABlAAEgTgAA+wEYAAAA+gAGAAAAcwBhAHQATQBvAGQAARjkAwD7AgQAAAD6AAD7AM0AAAAEyAAAAPr7ALgAAAACAAAAAFQAAAD6AAAAAAD7AEgAAAADQwAAAPoADvsAOgAAAAIAAAABFAAAAPoABAAAAHQAaQBuAHQAAYA4AQD7ARgAAAD6AAYAAABzAGEAdABNAG8AZAAB4JMEAPsAVgAAAPoAoIYBAPsASgAAAANFAAAA+gAO+wA8AAAAAgAAAAEWAAAA+gAFAAAAcwBoAGEAZABlAAEwdQAA+wEYAAAA+gAGAAAAcwBhAHQATQBvAGQAAUANAwD7AgQAAAD6AAD7BAQAAAAAAAAA";
            std::string sCode = "window.editor.asc_nativeOpenFile(\"" + sEmptyDocument + "\");";

            CefRefPtr<CefFrame> _frame = CefV8Context::GetCurrentContext()->GetFrame();
            _frame->ExecuteJavaScript(sCode, _frame->GetURL(), 0);
            return true;
        }
        else if (name == "SetDestinationDocumentPath")
        {
            CefRefPtr<CefV8Value> val = *arguments.begin();
            if (val->IsValid() && val->IsString())
            {
                m_sDocumentPath = val->GetStringValue().ToWString();
            }

            NSDirectory::CreateDirectory(m_sDocumentPath + L"/media");
            return true;
        }
        else if (name == "GetImageUrl")
        {
            std::vector<CefRefPtr<CefV8Value> >::const_iterator iter = arguments.begin();

            std::wstring sUrl = (*iter)->GetStringValue().ToWString(); ++iter;

            CefRefPtr<CefFrame> _frame = CefV8Context::GetCurrentContext()->GetBrowser()->GetFrame(m_sPasteFrameId);
            if (!_frame)
                _frame = CefV8Context::GetCurrentContext()->GetFrame();

            std::wstring sUrlBase = _frame->GetURL().ToWString();
            std::wstring sUrlFull = GetFullUrl(sUrl, sUrlBase);

            bool bIsBase64 = false;
            if (sUrl.find(L"data:") == 0)
            {
                std::wstring::size_type nPos = sUrl.find(L"base64");
                if (nPos != std::wstring::npos && nPos < 20)
                    sUrlFull = sUrl;
                bIsBase64 = true;
            }

            // delete file:///
            if (0 == sUrlFull.find(L"file:///"))
            {
                if (NSFile::CFileBinary::Exists(sUrlFull.substr(7)))
                    sUrlFull = sUrlFull.substr(7);
                else
                    sUrlFull = sUrlFull.substr(8);
            }
            else if (0 == sUrlFull.find(L"file:"))
                sUrlFull = sUrlFull.substr(5);

            std::wstring sReturn = GetImagePath(sUrlFull, bIsBase64);

            retval = CefV8Value::CreateString(sReturn);
            return true;
        }
        else if (name == "SaveDocument")
        {
            if (arguments.size() > 0)
            {
                CefRefPtr<CefV8Value> val = *arguments.begin();
                if (val->IsValid() && val->IsString())
                {
                    std::string sFile = val->GetStringValue().ToString();
                    NSFile::CFileBinary oFile;
                    oFile.CreateFileW(m_sDocumentPath + L"/Editor.bin");

                    BYTE* pDataDst = NULL;
                    int nDataDstLen = 0;
                    NSFile::CBase64Converter::Decode(sFile.c_str(), (int)sFile.length(), pDataDst, nDataDstLen);

                    oFile.WriteFile(pDataDst, (DWORD)nDataDstLen);
                    oFile.CloseFile();

                    RELEASEARRAYOBJECTS(pDataDst);
                }
            }
            else
            {
                std::string sCode = "window.Native.SaveDocument(window.editor.asc_nativeGetFile2());";

                CefRefPtr<CefFrame> _frame = CefV8Context::GetCurrentContext()->GetFrame();
                _frame->ExecuteJavaScript(sCode, _frame->GetURL(), 0);
                return true;
            }

            return true;
        }
        else if (name == "Exit")
        {
#ifdef ASC_HTML_FILE_INTERNAL_LOG
            std::string sLog = U_TO_UTF8((NSFile::GetProcessDirectory())) + "/convert.log";
            FILE* f = fopen(sLog.c_str(), "a+");
            fprintf(f, "Exit\n");
            fclose(f);
#endif

            CefRefPtr<CefProcessMessage> message = CefProcessMessage::Create("Exit");
            SEND_MESSAGE_TO_BROWSER_PROCESS(message);

            return true;
        }
        else if (name == "AddHtml")
        {
#ifdef ASC_HTML_FILE_INTERNAL_LOG
            std::string sLog = U_TO_UTF8((NSFile::GetProcessDirectory())) + "/convert.log";
            FILE* f = fopen(sLog.c_str(), "a+");
            fprintf(f, "AddHtml\n");
            fclose(f);
#endif

            m_sPasteFrameId = "pasteFrame";
            CefRefPtr<CefV8Value> val = *arguments.begin();
            if (val->IsValid() && val->IsString())
            {
                m_sPasteFrameId = val->GetStringValue().ToString();
            }

            std::string sCode = "window.editor.asc_AddHtml(\"" + m_sPasteFrameId + "\");";

            CefRefPtr<CefFrame> _frame = CefV8Context::GetCurrentContext()->GetFrame();
            _frame->ExecuteJavaScript(sCode, _frame->GetURL(), 0);
            return true;
        }        
        // Function does not exist.
        return false;
    }

    std::wstring GetFullUrl(const std::wstring& sUrl, const std::wstring& sBaseUrl)
    {
        std::wstring sUrlSrc = L"";
        if (NSFileDownloader::IsNeedDownload(sUrl))
        {
            sUrlSrc = sUrl;
        }
        else
        {
            if (0 == sUrl.find(wchar_t('/')))
            {
                // нужно брать корень сайта
                int nPos = sBaseUrl.find(L"//");
                if (nPos != std::wstring::npos)
                {
                    nPos = sBaseUrl.find(wchar_t('/'), nPos + 3);
                    if (nPos != std::wstring::npos)
                    {
                        sUrlSrc = sBaseUrl.substr(0, nPos);
                        sUrlSrc += sUrl;
                    }
                }
                if (sUrlSrc.empty())
                {
                    sUrlSrc = sBaseUrl;
                    sUrlSrc += (L"/" + sUrl);
                }
            }
            else
            {
                // брать место урла
                int nPos = sBaseUrl.find_last_of(wchar_t('/'));
                if (std::wstring::npos != nPos)
                {
                    sUrlSrc = sBaseUrl.substr(0, nPos);
                }
                else
                {
                    sUrlSrc = sBaseUrl;
                }
                sUrlSrc += (L"/" + sUrl);
            }
        }
        return sUrlSrc;
    }

    bool DownloadFile(const std::wstring& sUrl, const std::wstring& sDst, const std::wstring& sBaseUrl)
    {
        std::wstring sUrlSrc = GetFullUrl(sUrl, sBaseUrl);

        CFileDownloader oDownloader(sUrlSrc, false);
        oDownloader.SetFilePath(sDst);
        oDownloader.Start( 0 );
        while ( oDownloader.IsRunned() )
        {
            NSThreads::Sleep( 10 );
        }
        return oDownloader.IsFileDownloaded();
    }

    // Provide the reference counting implementation for this class.
    IMPLEMENT_REFCOUNTING(CAscEditorNativeV8Handler);
};

class ClientRenderDelegate : public client::ClientAppRenderer::Delegate {
 public:
  ClientRenderDelegate()
    : last_node_is_editable_(false)
  {
    sync_command_check = false;
  }

  virtual void OnWebKitInitialized(CefRefPtr<client::ClientAppRenderer> app) OVERRIDE {
    // Create the renderer-side router for query handling.
    CefMessageRouterConfig config;
    message_router_ = CefMessageRouterRendererSide::Create(config);
  }

  virtual void OnContextCreated(CefRefPtr<client::ClientAppRenderer> app,
                                CefRefPtr<CefBrowser> browser,
                                CefRefPtr<CefFrame> frame,
                                CefRefPtr<CefV8Context> context) OVERRIDE {

    message_router_->OnContextCreated(browser,  frame, context);

    if (!frame->IsMain())
        return;

    // add AscEditorNative
    CefRefPtr<CefV8Value> object = context->GetGlobal();

#ifdef CEF_2623
    CefRefPtr<CefV8Value> objNative = CefV8Value::CreateObject(NULL);
#else
    CefRefPtr<CefV8Value> objNative = CefV8Value::CreateObject(NULL, NULL);
#endif

    CAscEditorNativeV8Handler* pNativeHandlerWrapper = new CAscEditorNativeV8Handler();
    pNativeHandlerWrapper->sync_command_check = &sync_command_check;

    CefRefPtr<CefV8Handler> _nativeHandler = pNativeHandlerWrapper;

    CefRefPtr<CefV8Value> _nativeFunction1 = CefV8Value::CreateFunction("InitSDK", _nativeHandler);
    CefRefPtr<CefV8Value> _nativeFunction2 = CefV8Value::CreateFunction("OpenEmptyDocument", _nativeHandler);
    CefRefPtr<CefV8Value> _nativeFunction3 = CefV8Value::CreateFunction("SetDestinationDocumentPath", _nativeHandler);
    CefRefPtr<CefV8Value> _nativeFunction4 = CefV8Value::CreateFunction("SaveDocument", _nativeHandler);
    CefRefPtr<CefV8Value> _nativeFunction5 = CefV8Value::CreateFunction("Exit", _nativeHandler);
    CefRefPtr<CefV8Value> _nativeFunction6 = CefV8Value::CreateFunction("AddHtml", _nativeHandler);
    CefRefPtr<CefV8Value> _nativeFunction7 = CefV8Value::CreateFunction("GetImageUrl", _nativeHandler);

    objNative->SetValue("InitSDK", _nativeFunction1, V8_PROPERTY_ATTRIBUTE_NONE);
    objNative->SetValue("OpenEmptyDocument", _nativeFunction2, V8_PROPERTY_ATTRIBUTE_NONE);
    objNative->SetValue("SetDestinationDocumentPath", _nativeFunction3, V8_PROPERTY_ATTRIBUTE_NONE);
    objNative->SetValue("SaveDocument", _nativeFunction4, V8_PROPERTY_ATTRIBUTE_NONE);
    objNative->SetValue("Exit", _nativeFunction5, V8_PROPERTY_ATTRIBUTE_NONE);
    objNative->SetValue("AddHtml", _nativeFunction6, V8_PROPERTY_ATTRIBUTE_NONE);
    objNative->SetValue("GetImageUrl", _nativeFunction7, V8_PROPERTY_ATTRIBUTE_NONE);

    object->SetValue("Native", objNative, V8_PROPERTY_ATTRIBUTE_NONE);
  }

  virtual void OnContextReleased(CefRefPtr<client::ClientAppRenderer> app,
                                 CefRefPtr<CefBrowser> browser,
                                 CefRefPtr<CefFrame> frame,
                                 CefRefPtr<CefV8Context> context) OVERRIDE {
    message_router_->OnContextReleased(browser,  frame, context);
  }

  virtual void OnFocusedNodeChanged(CefRefPtr<client::ClientAppRenderer> app,
                                    CefRefPtr<CefBrowser> browser,
                                    CefRefPtr<CefFrame> frame,
                                    CefRefPtr<CefDOMNode> node) OVERRIDE {
    bool is_editable = (node.get() && node->IsEditable());
    if (is_editable != last_node_is_editable_)
    {
      // Notify the browser of the change in focused element type.
      last_node_is_editable_ = is_editable;
#if 0
      CefRefPtr<CefProcessMessage> message =
          CefProcessMessage::Create(kFocusedNodeChangedMessage);
      message->GetArgumentList()->SetBool(0, is_editable);
      browser->SendProcessMessage(PID_BROWSER, message);
#endif
    }
  }

  virtual bool OnProcessMessageReceived(
      CefRefPtr<client::ClientAppRenderer> app,
      CefRefPtr<CefBrowser> browser,
#ifndef MESSAGE_IN_BROWSER
      CefRefPtr<CefFrame> messageFrame,
#endif
      CefProcessId source_process,
      CefRefPtr<CefProcessMessage> message) OVERRIDE
{

    std::string sMessageName = message->GetName().ToString();

    return message_router_->OnProcessMessageReceived(
        browser,
#ifndef MESSAGE_IN_BROWSER
        messageFrame,
#endif
        source_process, message);
}

 private:
  bool last_node_is_editable_;
  bool sync_command_check;

  // Handles the renderer side of query routing.
  CefRefPtr<CefMessageRouterRendererSide> message_router_;

  IMPLEMENT_REFCOUNTING(ClientRenderDelegate);
};

void CreateRenderDelegates(client::ClientAppRenderer::DelegateSet& delegates) {
  delegates.insert(new ClientRenderDelegate);
}

}  // namespace client_renderer

void client::ClientAppRenderer::CreateDelegates(client::ClientAppRenderer::DelegateSet& delegates) {
  delegates.insert(new asc_client_renderer::ClientRenderDelegate);
}
